﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 增加员工社保表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SysPersonSocialSecurityScheme",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SchemeName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
                    SchemeCode = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    PaymentArea = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false),
                    SocialSecurityBase = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    PensionPersonal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    PensionCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    MedicalPersonal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    MedicalCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    UnemploymentPersonal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    UnemploymentCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    InjuryCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    MaternityCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    HousingFundBase = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    HousingFundPersonal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    HousingFundCompany = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    PersonalTotal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    CompanyTotal = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPersonSocialSecurityScheme", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "SysPersonSocialSecurity",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    SchemeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    SocialSecurityNo = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    HousingFundAccount = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    EnrollmentDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Status = table.Column<int>(type: "int", nullable: true),
                    PaymentMonth = table.Column<string>(type: "nvarchar(7)", maxLength: 7, nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPersonSocialSecurity", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysPersonSocialSecurity_SysPersonSocialSecurityScheme_SchemeId",
                        column: x => x.SchemeId,
                        principalTable: "SysPersonSocialSecurityScheme",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysPersonSocialSecurity_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonSocialSecurity_PersonId",
                table: "SysPersonSocialSecurity",
                column: "PersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonSocialSecurity_SchemeId",
                table: "SysPersonSocialSecurity",
                column: "SchemeId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysPersonSocialSecurity");

            migrationBuilder.DropTable(
                name: "SysPersonSocialSecurityScheme");
        }
    }
}
